﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Admin_DeThi_ChiTietDeThi : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            LoadDL();
            LoadData();
            LoadDDL();
        }
    }
    public void LoadDL() {
        int made = int.Parse(Request["MaDe"]);
        DeThiINFO dethi = DeThiDAL.GetInfo(made);

        lblTenDe.Text = dethi.TenDe;
        lblThangDiem.Text = dethi.ThangDiem.ToString();
        lblChuThich.Text = dethi.ChuThich;


    }

    private void LoadData()
    {

        List<LoaiCauHoiINFO> dsloaicauhoi = LoaiCauHoiDAL.listAll();
        ddltenloai.DataSource = dsloaicauhoi;
        ddltenloai.DataTextField = "TenLoai";
        ddltenloai.DataValueField = "MaLoai";
        ddltenloai.DataBind();
        ddltenloai.Items.Insert(0, new ListItem("Chọn loại câu hỏi", "0"));

        List<MonThiINFO> dsmonthi = MonThiDAL.listAll();
        ddltenmon.DataSource = dsmonthi;
        ddltenmon.DataTextField = "TenMon";
        ddltenmon.DataValueField = "MaMon";
        ddltenmon.DataBind();
        ddltenmon.Items.Insert(0, new ListItem("Chọn môn thi", "0"));

        List<DoKhoINFO> dsdokho = DoKhoDAL.listAll();
        ddldokho.DataSource = dsdokho;
        ddldokho.DataTextField = "DoKho";
        ddldokho.DataValueField = "MaDoKho";
        ddldokho.DataBind();
        ddldokho.Items.Insert(0, new ListItem("Tất cả", "0"));

        txtMaDe.Value = Request["MaDe"];
    }

    private void LoadDDL()
    {
        int made = int.Parse(Request["MaDe"]);
        DataTable ds = DeThiDAL.listByCauHoi(made);
        GridView1.DataSource = ds;
        GridView1.DataBind();
    }
    protected void refresh_Click(object sender, EventArgs e)
    {
        LoadDDL();
    }
}